<template>
	<view>
		<view class="center " style="flex-wrap: wrap;">
			<view class="bb" @tap="" style="">
				<view class="mb-3  fs28 ls2">账户余额</view>
				<view class="">{{uInfo.hasmoney}}</view>
			</view>
			<view class="bb" @tap="">
				<view class="mb-3  fs28 ls2">报单积分</view>
				<span>{{uInfo.hasbill}}</span>
			</view>
			<view class="bb" @tap="">
				<view class="mb-3  fs28 ls2">尊享积分</view>
				<span>{{uInfo.hascp}}</span>
			</view>
			<view class="bb" @tap="">
				<view class="mb-3  fs28 ls2">绿色积分</view>
				<span>{{uInfo.hasshop}}</span>
			</view>

		</view>
		
		<view class="" style="width: 100%;display: flex;justify-content: center;">
			<view class="" style="width:40%;padding:10upx 0;background-color: #fff;display: flex;justify-content: center;font-weight: bold;border-radius: 10upx;;">
				会员专区
			</view>
			
		</view>
		<view class="center " style="flex-wrap: wrap;">
			<view class="bb" @tap="goMoneyChange(1)">
				<view class="mb-3  fs28 ls2">零售奖</view>
				<span>{{uInfo.bonus1}}</span>
			</view>
			<view class="bb" @tap="goMoneyChange(2)">
				<view class="mb-3  fs28 ls2">销售提成</view>
				<span>{{uInfo.bonus2}}</span>
			</view>
		</view>
		
		<view class="" style="width: 100%;display: flex;justify-content: center;">
			<view class="" style="width:40%;padding:10upx 0;background-color: #fff;display: flex;justify-content: center;font-weight: bold;border-radius: 10upx;">
				代理商专区
			</view>
			
		</view>
		
		<view class="center " style="flex-wrap: wrap;">
			<view class="bb" @tap="goMoneyChange(3)">
				<view class="mb-3  fs28 ls2">推荐奖</view>
				<span>{{uInfo.bonus3}}</span>
			</view>
			<view class="bb" @tap="goMoneyChange(4)">
				<view class="mb-3  fs28 ls2">业绩提成</view>
				<span>{{uInfo.bonus4}}</span>
			</view>
			<view class="bb" @tap="goMoneyChange(5)">
				<view class="mb-3  fs28 ls2">培育奖</view>
				<span>{{uInfo.bonus5}}</span>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				uInfo: {}
			}
		},
		onLoad() {
			uni.showLoading({
				title: '加载中...'
			});

			if (this.hasLogin) {
				this.loadData();
			}

			setTimeout(() => {
				uni.hideLoading();
			}, 600)

			uni.$on('changeNickname', (option) => {
				this.uIfo.nickname = option.nickname;
			})
		},
		onPullDownRefresh() {
			this.loadData()
			setTimeout(function() {
				uni.stopPullDownRefresh()
			}, 1000);
		},
		computed: {
			...mapState(['hasLogin']),
		},
		methods: {
			...mapMutations(['logout']),

			async loadData() {
				let token = uni.getStorageSync('token');

				if (!token) {
					this.$api.msg('token缺失！');
				}
				let url = '/finance';
				let res = await this.$myRequest({
					url: url,
					data: {
						token: token
					},
					methods: 'post'
				})

				let info = res.data.data;
				this.uInfo = info;
			},

			/**
			 * 财务流水
			 * @param {Object} type
			 */
			goMoneyChange(type) {
				uni.navigateTo({
					url: '/pages/finance/money_change?type=' + type
				})
			}
		}
	}
</script>

<style>
	.btn {
		color: white;
		background-color: #29ad97;
		border-radius: 50rpx;
		margin: 100rpx 20rpx;
		font-size: 32upx;
		letter-spacing: 2upx;
	}

	page {
		background-color: #f0efee;
	}

	.center {
		width: 94%;
		height: 100%;
		/* background-color: white; */
		margin: 20rpx auto;
		border-radius: 20rpx;
		display: flex;
		justify-content: space-between;
	}

	.bb {
		border: 1rpx solid #f3f3f3;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 30vw;
		height: 70px;
		background: #f8f9fc;
		position: relative;
		border-radius: 8px;
		background-position: 0 0;
		background-size: 69px 84px;
		background-repeat: no-repeat;
		margin-top: 20upx;
	}

	.span {
		margin-right: 40upx;
	}

	.mb-3 {
		margin-bottom: 16upx;
	}
</style>
